package com.heima.kafka.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloKafkaController {
    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    /**
     * kafka入门案例
     * @return
     */
    @GetMapping("/hello")
    public String helloKafka(){
        kafkaTemplate.send("kafka-topic","你好,kafka");
        return "ok";
    }
}
